package com.siwei.mes.controller.laboratory;


import com.siwei.mes.common.result.ApiResult;
import com.siwei.mes.common.result.Json;
import com.siwei.mes.entity.UploadLaboratoryEntity;
import com.siwei.mes.service.laboratory.DownloadLaboratoryService;
import com.siwei.mes.service.laboratory.FinishLaboratoryService;
import com.siwei.mes.service.laboratory.UploadLaboratoryService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 同步上海协会接口
 *
 * @Description: 同步上海协会接口
 * @Version: 1.0
 */
@RestController
@RequestMapping("laboratory")
public class LaboratoryController {
    @Resource
    private DownloadLaboratoryService downloadLaboratory;
    @Resource
    private UploadLaboratoryService uploadLaboratoryService;
    @Resource
    private FinishLaboratoryService finishLaboratoryService;

    @ApiOperation(value = "下载上海协会数据")
    @PostMapping("/download")
    public Json downloadLaboratory(@RequestBody UploadLaboratoryEntity entity) {
        downloadLaboratory.downloadLaboratory(entity);
        return Json.succ().data(new ApiResult());
    }

    @ApiOperation(value = "下载上海协会报告数据")
    @PostMapping("/downloadRepoet")
    public Json downloadReportLaboratory(@RequestBody UploadLaboratoryEntity entity) {
        downloadLaboratory.downloadReportLaboratory(entity);
        return Json.succ().data(new ApiResult());
    }

    @ApiOperation(value = "上传上海协会数据")
    @PostMapping("/upload")
    public Json uploadLaboratory(@RequestBody UploadLaboratoryEntity entity) {
        uploadLaboratoryService.generateLedger(entity);
        return Json.succ().data(new ApiResult());
    }


    @ApiOperation(value = "保存/完成台账同步协会")
    @PostMapping("/finish")
    public Json finishLaboratory(@RequestBody UploadLaboratoryEntity entity) {
        finishLaboratoryService.finishLaboratory(entity);
        return Json.succ().data(new ApiResult());
    }


    @ApiOperation(value = "取样")
    @PostMapping("/addYpShuiNi")
    public Json addYpShuiNi(@RequestBody UploadLaboratoryEntity entity) {
        uploadLaboratoryService.samplingOperation(entity);
        return Json.succ().data(new ApiResult());
    }


    @ApiOperation(value = "进料")
    @PostMapping("/laboratory")
    public Json addImportList(@RequestBody UploadLaboratoryEntity entity) {
        uploadLaboratoryService.incomingMaterials(entity);
        return Json.succ().data(new ApiResult());
    }


    @ApiOperation(value = "添加试验台账")
    @PostMapping("/addExperiment")
    public Json addExperiment(@RequestBody UploadLaboratoryEntity entity) {
        uploadLaboratoryService.generateLedger(entity);
        return Json.succ().data(new ApiResult());
    }
}
